﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Work01_P4
{
    internal class MyQueue<T>
    {

            private T[] queues;
            private int first;
            private int list;
            private int size;
            public MyQueue(int size)
            {
                this.size = size;
                queues = new T[size];
            }

           
            public int Count
            {
                get
                {
                    return first;
                }
            }

        
            public T Remove()
            {
                if (first != 0)
                {
                    first--;
                    return queues[list++];
                }
                else
                {
                    throw new Exception("队列为空");
                }
            }

            public void Add(T item)
            {
                if (Count < size)
                {

                    queues[first++] = item;
                }
                else
                {
                  throw new Exception("队列已满，无法入队");
                }
            }

          

        }
    }




